<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>login</title>
    <style type="text/css">
        body {
            text-align: center;
            padding: 0;
            margin: 0;
            font-size: 20px;
            background: skyblue;
        }
        label {
            width: 100px;
            display: inline-block;
        }
        input,button {
            border: 1px solid #eee;
            font-size: 20px;
        }
        button {
            margin-right: 30px;
        }
        div {
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <h2>后台管理系统</h2>
    <div>
        <label>用户名：</label>
        <input type="text" value="" id="user" />
    </div>
    <div>
        <label>密  码：</label>
        <input type="password" value="" id="pass" />
    </div>
    <button onclick="doLogin()">登录</button>
    <button onclick="goRegister()">注册</button>
</body>
</html>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script>
function doLogin() {
    const user = $('#user').val();
    const pass = $('#pass').val();
    const params = {
        us: user,
        ps: pass
    };
    const url = 'http://localhost:3000/user/login';

    $.post(url, params, data => {
        if (!data.errno) {
            alert('login success');
            window.location.href = 'http://localhost:3000/public/html/index.html';
        }
        else {
            alert('login fail');
        }
    });
}
function goRegister() {
    window.location.href = 'http://localhost:3000/public/html/register.html';
}
</script>